from run_test import rtest, print_sep

import sys
import numpy as np
from os.path import abspath, join, dirname, curdir
import os.path

global_a = 1


def te1():
    local_b = 2
    if not global_a is None:
        print('exist global a_')
    if not local_b is None:
        print('exist local_b')
    if 'global_a' in globals():
        print(globals())
        print('global a_ in global()')
    if 'local_b' in locals():
        print(locals())
        print('local b in locals()')


def te0():
    a = 1
    b = 1
    c = 1


def te2():
    c = a = (b := 2)
    print(a)
    print(b)
    print(c)
    print(486.220174 + 13.779826)
    print(4194304 / 1024 / 1024)


def te3():
    a = 0.329517
    b = 0.329521
    print((a - b) / b * 100)

    a = 148.3694
    b = 148.3692
    print((a - b) / b * 100)

    a = 5.859245
    b = 5.859223
    print((a - b) / b * 100)

    print('film des:')
    a = -1.030608
    b = -1.030625
    print((a - b) / b * 100)

    print('film dep:')
    a = 1.002205
    b = 1.002223
    print((a - b) / b * 100)

    iM = 0.059
    iF = 96485
    iN = 2
    print(f'Test coe {iM / iN / iF}')

    i1 = 486.220267
    i2 = 13.779829
    itot = i1 + i2
    print(f'total curr {itot}')
    print(f'i1 percent {i1 / itot}')
    print(f'i2 percent {i2 / itot}')

    a = np.array([1, 2, 3])
    print(np.sqrt(1 + 4 + 9))
    print(a, np.linalg.norm(a))


def te4():
    a = np.eye(3, 1).ravel()
    print(a)


def te5():
    a = np.arange(12).reshape((3, 4))
    print(a)
    print(a[:, 1:2])
    print(a[1:2, :])


def te6():
    for i in range(3, 0, -1):
        print(i)


def te7():
    a = np.arange(6).reshape(2, 3)
    for x in np.nditer(a, flags=['external_loop'], order='F'):
        print(x)


def te8():
    a = np.array([66, 77])
    print(a[:0])
    print(a[1:1])

    for i in range(1, 2):
        print(i)


if __name__ == '__main__':
    rtest(te1)
    rtest(te2)
    rtest(te3)
    rtest(te4)
    rtest(te5)
    rtest(te6)
    rtest(te7)
    rtest(te8)
